package com.wxd.woff.table.name;

import com.wxd.woff.AbstractOTFDataStream;
import com.wxd.woff.WoffFont;

import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 *
 * @author: wangxindong
 * @date: 2018/9/2-07:28
 */
public class NameRecord {

    public static final int PLATFORM_UNICODE = 0;
    public static final int PLATFORM_MACINTOSH = 1;
    public static final int PLATFORM_ISO = 2;
    public static final int PLATFORM_WINDOWS = 3;

    public static final int ENCODING_UNICODE_1_0 = 0;
    public static final int ENCODING_UNICODE_1_1 = 1;
    public static final int ENCODING_UNICODE_2_0_BMP = 3;
    public static final int ENCODING_UNICODE_2_0_FULL = 4;

    public static final int LANGUGAE_UNICODE = 0;

    public static final int ENCODING_WINDOWS_SYMBOL = 0;
    public static final int ENCODING_WINDOWS_UNICODE_BMP = 1;
    public static final int ENCODING_WINDOWS_UNICODE_UCS4 = 10;

    public static final int LANGUGAE_WINDOWS_EN_US = 0x0409;

    public static final int ENCODING_MACINTOSH_ROMAN = 0;

    public static final int LANGUGAE_MACINTOSH_ENGLISH = 0;

    public static final int NAME_COPYRIGHT = 0;
    public static final int NAME_FONT_FAMILY_NAME = 1;
    public static final int NAME_FONT_SUB_FAMILY_NAME = 2;
    public static final int NAME_UNIQUE_FONT_ID = 3;
    public static final int NAME_FULL_FONT_NAME = 4;
    public static final int NAME_VERSION = 5;
    public static final int NAME_POSTSCRIPT_NAME = 6;
    public static final int NAME_TRADEMARK = 7;

    private int platformId;
    private int encodingID;
    private int languageId;
    private int nameId;
    private int length;
    private int offset;
    private String string;

    public void initData(WoffFont font, AbstractOTFDataStream stream) throws IOException {
        platformId = stream.readUnsignedShort();
        encodingID = stream.readUnsignedShort();
        languageId = stream.readUnsignedShort();
        nameId = stream.readUnsignedShort();
        length = stream.readUnsignedShort();
        offset = stream.readUnsignedShort();
    }


    public int getPlatformId() {
        return platformId;
    }

    public void setPlatformId(int platformId) {
        this.platformId = platformId;
    }

    public int getEncodingID() {
        return encodingID;
    }

    public void setEncodingID(int encodingID) {
        this.encodingID = encodingID;
    }

    public int getLanguageId() {
        return languageId;
    }

    public void setLanguageId(int languageId) {
        this.languageId = languageId;
    }

    public int getNameId() {
        return nameId;
    }

    public void setNameId(int nameId) {
        this.nameId = nameId;
    }

    public int getLength() {
        return length;
    }

    public void setLength(int length) {
        this.length = length;
    }

    public int getOffset() {
        return offset;
    }

    public void setOffset(int offset) {
        this.offset = offset;
    }

    public String getString() {
        return string;
    }

    public void setString(String string) {
        this.string = string;
    }

    @Override
    public String toString() {
        return "NameRecord{" +
                "platformId=" + platformId +
                ", encodingID=" + encodingID +
                ", languageId=" + getLanguageId() +
                ", nameId=" + nameId +
                ", length=" + length +
                ", offset=" + offset +
                '}';
    }
}
